<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="../template/layout.xhtml">

<ui:define name="cssStyle">
.ui-widget-content{
border:0;
}

</ui:define>

	<ui:define name="content">
		<h:form id="form" enctype="multipart/form-data" >
			<p:growl globalOnly="true" showDetail="true" autoUpdate="true" />
			<h1 class="titulo-h1">Pesquisar Editais</h1>
					<h:panelGrid columns="2" style="width:100%" >  
					
					<p:outputLabel value="Tipo:"/>
					<p:selectOneMenu style="width:100px;" value="#{editalMB.filter.tipo}">
						<f:selectItem itemLabel="Selecione" itemValue="Selecione" />
						<f:selectItem itemLabel="Produto" itemValue="Produto" />
						<f:selectItem itemLabel="Servico" itemValue="Servico"/>
					</p:selectOneMenu>
					
					<p:outputLabel value="Estado:"/>
					<p:selectOneMenu style="width:100px;" value="#{editalMB.filter.estado}">
						<f:selectItem itemLabel="Selecione" itemValue="Selecione" />
						<f:selectItem itemLabel="Aberto" itemValue="Aberto" />
						<f:selectItem itemLabel="Fechado" itemValue="Fechado"/>
					</p:selectOneMenu>
					
					<p:outputLabel value="Data para abertura:" />
					<p:calendar value="${editalMB.filter.dataAbertura}" pattern="dd/MM/yyyy HH:mm" effect="explode"/> 
					
					<p:outputLabel value="Data para fechamento:" />
					<p:calendar value="${editalMB.filter.dataFechamento}" pattern="dd/MM/yyyy HH:mm" effect="explode" /> 
					
					<h:outputText value="Nome:" />
					<p:inputText id="nome" value="${editalMB.filter.nome}"/>
					
					<p:commandButton style="margin-top:10px" value="Pesquisar" ajax="false" action="#{editalMB.listar}"/>  
					  
				</h:panelGrid>
		
		<h1 style="margin-top:20px;" class="titulo-h1">Resultado da Consulta</h1>
				<p:dataGrid id="listaEdital" 
							var="item"  
							value="#{editalMB.lista}"
							columns="3"
							rowIndexVar="i"							
							>  
					<p:column>
						<p:panel id="item" styleClass="itemEdital" style="text-align:center;width:300px;">  
							<h2 class="titulo-h2">#{item.produto.nome}</h2>
							
							
							<center>
							<h:panelGrid columns="1" style="width:200px; text-align:center;" >  
								
								<p:commandLink  action="#{editalMB.mostrarEdital(item)}" update=":form:showEdital" oncomplete="showEdital.show();">
	               					<center>
	               					<p:graphicImage value="#{editalMB.getImageFromHell()}" style="width:200px;height:200px;">
										<f:param name="id_edital" value="#{item.idEdital}"/> 
									</p:graphicImage>
									</center>
								</p:commandLink>
								
								<h:panelGrid columns="2" style="width:200px;text-align:center;" >  
									<h:outputText value="#{item.dataAbertura}" styleClass="dataEdital">
										<f:convertDateTime pattern="dd/MM/yyyy"/>  
									</h:outputText>
									
									<h:outputText value="#{item.dataFechamento}" styleClass="dataEdital">
										<f:convertDateTime pattern="dd/MM/yyyy"/>  
									</h:outputText>
								</h:panelGrid>
							</h:panelGrid>
							</center>
						</p:panel> 
					</p:column>  
				
				</p:dataGrid> 
			
			<p:dialog widgetVar="showEdital" header="Detalhes do Edital" showEffect="fade" modal="true" id="modalImage" rendered="#{editalMB.existeEditaisDisponiveis()}">
				<h:panelGrid columns="1" style="width:400px;" id="showEdital">
					<h:outputText value="#{editalMB.bean.produto.nome}" styleClass="titulo" style="font-weight:bold"/>
					
					<p:graphicImage value="#{editalMB.getImageFromHell()}" style="width:400px;height:400px;">
						<f:param name="id_edital" value="#{editalMB.bean.idEdital}"/> 
					</p:graphicImage>
					
					<h:outputText value="#{editalMB.bean.produto.descricao}"/>
						
			
					<f:facet name="footer">
						<h:panelGrid columns="4" style="width:400px;" styleClass="dialog">
							<h:outputText value="Aberto do dia " style="font-weight:bold;width:1000px;"/>
							
						  	<h:outputText value="#{editalMB.bean.dataAbertura}" styleClass="dataEdital">
								<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT-03:00"/>  
							</h:outputText>
							
							<h:outputText value=" até " styleClass="titulo" style="font-weight:bold"/>
						  	<h:outputText value="#{editalMB.bean.dataFechamento}" styleClass="dataEdital">
								<f:convertDateTime  pattern="dd/MM/yyyy HH:mm" timeZone="GMT-03:00"/>  
							</h:outputText>
							<center>
							<h:panelGrid style="margin-left:-40px;" rendered="#{loginMB.isUsuarioComum()}" >
								<p:column>
									<h:outputText value="Efetuar Lance:" />
									<p:inputText  value="${lanceMB.bean.valor}"/>								
									
								</p:column>
								<p:column>
									<p:commandButton style="margin-top:-34px;float:right;right:-76px;" value="Efetuar" ajax="false" action="#{lanceMB.efetuarLance(editalMB.bean)}"/>
			     				</p:column>
			     			</h:panelGrid>
			     			</center>  
						</h:panelGrid>
						
						
			        </f:facet>  
		        </h:panelGrid>  
			</p:dialog>
				
		</h:form>
	</ui:define>

</ui:composition>